import ChatTTS
import numpy as np
from scipy.io.wavfile import write

chat = ChatTTS.Chat()
chat.load(compile=False) # Set to True for better performance

texts = []
# texts.append("开车时请不要长时间闭眼")
# texts.append("开车时请不要长时间打哈欠")
# texts.append("开车时请不要长时间左顾右盼")
# texts.append("开车时请不要长时间打电话")
texts.append("抱歉,我无法连接到网络,正在尝试切换网络,暂时无法回答你哦")

wavs = chat.infer(texts)

# for i in range(len(wavs)):
wav_data = (wavs[0] * 32767).astype(np.int16)
write(f"basic_output{4}.wav", 24000, wav_data)